package edu.pku.sei.autounit.generator;



import edu.pku.sei.autounit.core.Variable;
import edu.pku.sei.autounit.core.VariableFactory;
import edu.pku.sei.autounit.core.VariableGenerator;
import edu.pku.sei.autounit.filter.Filter;
import edu.pku.sei.autounit.reflect.Class;
import edu.pku.sei.autounit.reflect.Method;
import edu.pku.sei.autounit.reflect.Type;
import edu.pku.sei.autounit.util.NameFactory;


public class ReturnValueGenerator implements VariableGenerator {

	
	public Variable generate(Type type,String name,VariableFactory vf,NameFactory nf) {
		if(!(type instanceof Class))
			return null;
		Class c = (Class)type;
		for(Method m:c.getPublicMethods()){
			if(m.isStatic()&&type.isAssignableFrom(m.getReturnType())){
				Type [] tps = m.getParameters();
				Variable []ps = new Variable[tps.length];
				for(int i=0;i<ps.length;i++)
					ps[i] = vf.getVariable(tps[i], nf.getName(m.getName(), NameFactory.PARAMETER), vf, nf);
				return new ReturnValue(type,name,m,null,ps);
			}
		}
		return null;
	}
	
	
	public Variable generate(Type type, String name, Filter fliter,
			VariableFactory vf, NameFactory nf) {
		// TODO Auto-generated method stub
		return null;
	}
	
	
}
